﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for ValidatorFactory
/// </summary>
public static class ValidatorFactory
{
    private static Simple_ModelItemValidator m_simple = new Simple_ModelItemValidator();
    private static Strict_ModelItemValidator m_strict = new Strict_ModelItemValidator();

    private static iModelItemValidator m_currentValidator;

	public static bool SimpleValidation(ModelItem a_item)
    {
        m_currentValidator = m_simple;
        return m_currentValidator.Validate(a_item);
    }

    public static bool StrictValidation(ModelItem a_item)
    {
        m_currentValidator = m_strict;
        return m_currentValidator.Validate(a_item);        
    }

    /// <summary>
    /// Returns error message from current validator
    /// </summary>
    /// <returns></returns>
    public static string GetErrorMsg()
    {
        if (m_currentValidator != null)
        {
            return m_currentValidator.ErrorMsg;
        }
        else
        {
            return "";
        }        
    }
}